<template>
  <div>
    <input type="text" placeholder="请输入用户名" v-model="username">
    <button @click="hdClick">登录</button>
  </div>
</template>

<script>
export default {
  data () {
    return {
      username: '',

 
    }
  },
  methods: {
    hdClick(){
      const username = this.username.trim()
      if(!username.length) return alert('请输入用户名')

      let key = `username${new Date().getTime()}`
      // 判断username有无重复
      localStorage.setItem('key', key)
      localStorage.setItem(`${key}`, username)
      
      this.$router.push('/home')
    }
  }
}
</script>
 
<style lang = "less" scoped>
  
</style>